namespace StockSharp.Algo.Strategies.Reporting;

/// <summary>
/// The interface describe report generator for strategies.
/// </summary>
public interface IReportGenerator
{
	/// <summary>
	/// Name.
	/// </summary>
	string Name { get; }

	/// <summary>
	/// Extension without leading dot char.
	/// </summary>
	string Extension { get; }

	/// <summary>
	/// To add <see cref="Order"/> to the report. <see cref="Order"/> are added by default.
	/// </summary>
	bool IncludeOrders { get; set; }

	/// <summary>
	/// To add <see cref="MyTrade"/> to the report. <see cref="MyTrade"/> are added by default.
	/// </summary>
	bool IncludeTrades { get; set; }

	/// <summary>
	/// Encoding.
	/// </summary>
	Encoding Encoding { get; set; }

	/// <summary>
	/// To generate the report.
	/// </summary>
	/// <param name="strategy"><see cref="Strategy"/>.</param>
	/// <param name="stream">The stream to write the report to.</param>
	/// <param name="cancellationToken"><see cref="CancellationToken"/>.</param>
	ValueTask Generate(Strategy strategy, Stream stream, CancellationToken cancellationToken);
}

/// <summary>
/// The base report generator for strategies.
/// </summary>
public abstract class BaseReportGenerator : IReportGenerator
{
	/// <summary>
	/// Initialize <see cref="BaseReportGenerator"/>.
	/// </summary>
	protected BaseReportGenerator()
	{
	}

	/// <inheritdoc />
	public bool IncludeOrders { get; set; } = true;

	/// <inheritdoc />
	public bool IncludeTrades { get; set; } = true;

	private Encoding _encoding = Encoding.UTF8;

	/// <inheritdoc />
	public Encoding Encoding
	{
		get => _encoding;
		set => _encoding = value ?? throw new ArgumentNullException(nameof(value));
	}

	/// <inheritdoc />
	public abstract string Name { get; }

	/// <inheritdoc />
	public abstract string Extension { get; }

	/// <inheritdoc />
	public abstract ValueTask Generate(Strategy strategy, Stream stream, CancellationToken cancellationToken);
}